package com.user.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.user.utils.*;
import com.user.bean.Mayuan;

/*持久层接口，封装了对mayuan表的增删改查方法功能*/
public interface MayuanMapper {

//	定义表名
	public static final String table="mayuan";

//  查询mayuan表中的所有数据
	@Select("select * from "+DBUtils.perfix+table+DBUtils.sufix+"")
	List<Mayuan> selectByExample(Mayuan mayuan);
	
//  根据主键id查询mayuan表中对应的数据
	@Select("select * from "+DBUtils.perfix+table+DBUtils.sufix+" where "+DBUtils.perfix+"id"+DBUtils.sufix+"=#{id}")
	Mayuan selectByPrimaryKey(Integer id);
	
//  向mayuan表中的添加一条数据
	@Insert("insert into "+DBUtils.perfix+table+DBUtils.sufix+" values(#{id},#{topic},#{topic_ans},#{answer},#{grad},#{multiple})")
	int insertSelective(Mayuan mayuan);

//  根据主键id更新mayuan表中对应的数据
	@Update("update "+DBUtils.perfix+table+DBUtils.sufix+" set "+DBUtils.perfix+"id"+DBUtils.sufix+"=#{id},"+DBUtils.perfix+"topic"+DBUtils.sufix+"=#{topic},"+DBUtils.perfix+"topic_ans"+DBUtils.sufix+"=#{topic_ans},"+DBUtils.perfix+"answer"+DBUtils.sufix+"=#{answer},"+DBUtils.perfix+"grad"+DBUtils.sufix+"=#{grad},"+DBUtils.perfix+"multiple"+DBUtils.sufix+"=#{multiple} where "+DBUtils.perfix+"id"+DBUtils.sufix+"=#{id}")
	int updateByPrimaryKey(Mayuan mayuan);
	
//  根据主键id删除mayuan表中对应的数据
	@Delete("delete from "+DBUtils.perfix+table+DBUtils.sufix+" where "+DBUtils.perfix+"id"+DBUtils.sufix+"=#{id}")
	int deleteByPrimaryKey(Integer id);
}